namespace HelpDesk.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class InitialCreated : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.UserProfile",
                c => new
                    {
                        UserId = c.Int(nullable: false, identity: true),
                        UserName = c.String(),
                        FirstName = c.String(),
                        LastName = c.String(),
                    })
                .PrimaryKey(t => t.UserId);
            
            CreateTable(
                "dbo.Activities",
                c => new
                    {
                        ActivityID = c.Int(nullable: false, identity: true),
                        Text = c.String(nullable: false),
                        Created = c.DateTime(nullable: false),
                        Ticket_TicketID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ActivityID)
                .ForeignKey("dbo.Tickets", t => t.Ticket_TicketID, cascadeDelete: true)
                .Index(t => t.Ticket_TicketID);
            
            CreateTable(
                "dbo.Tickets",
                c => new
                    {
                        TicketID = c.Int(nullable: false, identity: true),
                        Title = c.String(nullable: false),
                        Description = c.String(nullable: false),
                        Created = c.DateTime(nullable: false),
                        Customer_UserId = c.Int(nullable: false),
                        SupportStaff_UserId = c.Int(),
                    })
                .PrimaryKey(t => t.TicketID)
                .ForeignKey("dbo.UserProfile", t => t.Customer_UserId, cascadeDelete: true)
                .ForeignKey("dbo.UserProfile", t => t.SupportStaff_UserId)
                .Index(t => t.Customer_UserId)
                .Index(t => t.SupportStaff_UserId);
            
            CreateTable(
                "dbo.Departments",
                c => new
                    {
                        DepartmentID = c.Int(nullable: false, identity: true),
                        DepartmentName = c.String(nullable: false),
                        IsActive = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.DepartmentID);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.Tickets", new[] { "SupportStaff_UserId" });
            DropIndex("dbo.Tickets", new[] { "Customer_UserId" });
            DropIndex("dbo.Activities", new[] { "Ticket_TicketID" });
            DropForeignKey("dbo.Tickets", "SupportStaff_UserId", "dbo.UserProfile");
            DropForeignKey("dbo.Tickets", "Customer_UserId", "dbo.UserProfile");
            DropForeignKey("dbo.Activities", "Ticket_TicketID", "dbo.Tickets");
            DropTable("dbo.Departments");
            DropTable("dbo.Tickets");
            DropTable("dbo.Activities");
            DropTable("dbo.UserProfile");
        }
    }
}
